<?php
	function ajax_gold(){
		$Link = $Link2 = '';
		$dir='cache/';
		if(!is_dir($dir)) mkdir($dir,0755,true);
		$Link = $dir.'tygiavang.xml';
		$Link2 = 'http://www.sjc.com.vn/xml/tygiavang.xml';
		$content = @file_get_contents($Link2);
		if($content==''){
			$content = @file_get_contents($Link);
		}else{
			copy($Link2,$Link);
		}
		$xml=simplexml_load_string($content);
		return $xml;
	}

	echo "<tr><td>";
	if(empty($_SESSION['lang'])) echo "Name</td><td>";

	else echo "Tên</td><td>";

	if(empty($_SESSION['lang'])) echo "Sell</td><td>";

	else echo "Bán</td><td>";

	if(empty($_SESSION['lang'])) echo "Buy</td></tr>";

	else echo "Mua</td></tr>";

	$data_gold = ajax_gold();
	foreach($data_gold->ratelist->city as $item){
		if ($item['name'] == 'Hồ Chí Minh') {
  			if(count($item->item)>1){
	  			foreach($item->item as $t){
	  	            echo "<tr><td>".$t['type']."</td>";
	  	            echo "<td>".$t['sell']."</td>";
	  	            echo "<td>".$t['buy']."</td></tr>";
	  	            //<td class=" //if( $t['type'] == 'Vàng SJC 1L'){echo 'goldPrice';} ">  //echo $t['sell'] </td>
				}
			}
		}
	}
